home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-17 | 3.9 KB | 125 lines | [TEXT/ttxt] |
- *********************************************************
- * *
- * Process File *
- *********************************************************
- Procedure Process_File() Public
- Local Command As Integer
- Local Ret As Integer
-
- Local AppStruct As Structure
- Local AvRefNum As Word
- Local Atype As Integer
- Local AversNum As Byte
- Local Afiller As Byte
- Local AfileName As Str255 [64]
- Endstruct
-
- * find out if we have been asked to open a file or print a file
- Command=GetAppMessage()
-
- Do Case
- Case Command=0 ' Open file
- * get details of the file to open (first one only)
- AppStruct=GetAppFile(1)
- Do Show_File_Details(Integer(AvRefNum),String(AfileName))
- Break
- Case Command=1 ' Print file
- * reject as this program does not print files
- Ret=MsgBox("FileInfo does not print files","End","")
- End
- Endcase
- Return
-
- *********************************************************
- * *
- * Show File Details *
- *********************************************************
- Procedure Show_File_Details(RefNum,fileName)
- Parameter RefNum As Integer
- Parameter fileName As String
- Local Ret As Word
- Local fName As Str255
-
- Local paramBlock As Structure
- Local Filler1 As Char [12]
- Local ioCompletion As Integer
- Local ioResult As Word
- Local ioNamePtr As Integer
- Local ioVRefNum As Word
- Local ioFRefNum As Word
- Local ioFVersNum As Byte
- Local Filler2 As Byte
- Local ioFDirIndex As Word
- Local ioFlAttrib As Byte
- Local Filler3 As Byte
- Local pFInfo As Char [16]
- Local ioDirID As Integer
- Local Filler4 As Char [56]
- Endstruct
-
- Local FInfo As Structure
- Local fdType as Integer
- Local fdCreator As Integer
- Local fdFlags As Word
- Local fdLocation As Integer
- Local fdFldr As Word
- Endstruct
-
- Local UserItemType As Word
- Local DialogItem As Integer
-
- Local UserItemRect As Structure
- Local R1 As Word
- Local R2 As Word
- Local R3 As Word
- Local R4 As Word
- Endstruct
-
- * Set up paramBlock for PBGetCatInfo call
- ioCompletion=0
- fName=Str255(fileName)
- ioNamePtr=Varptr(fName)
- ioVRefNum=Word(RefNum)
- ioFDirIndex=0
- ioDirID=0
-
- Ret=_PBGetCatInfo(paramBlock)
-
- If Integer(Ret)=0
- FInfo=pFInfo
- FInfoForm.FType.Value=IntToChars(fdType)
- FInfoForm.FCreator.Value=IntToChars(fdCreator)
- Else
- Ret=MsgBox("Error in PBGetCatInfo","End","")
- End
- Endif
- Return
-
- *********************************************************
- * *
- * Convert Integer to Chars *
- *********************************************************
- Function IntToChars(InInt) Returning String
- Parameter InInt As Integer
- Local I As Integer
- Local ChString As String [4]
-
- * File types and Creator types are stored as a 32 bit integer with 4
- * characters encoded within each byte. Use Peek and Varptr to get each byte.
- ChString=""
- For I=1 to 4
- ChString=ChString+Chr(Peek(Varptr(InInt)+I-1))
- Next I
-
- Return ChString
-
- *********************************************************
- * *
- * Click Event on OK Button *
- *********************************************************
- Procedure FInfoForm.OKButton.Click()
- FInfoForm.CloseWindow
- End
- Return
-
-